<template>
	<view class="">
		<tabqihuan :sd="ihbhbgsd" :datas="datas"></tabqihuan>
		<view class="pd parentssert">
			<view class="jjhnmkhbnkdt fz32 cf" :class="idsdf==idx?'act':''" @tap="qoehuan(idx)" v-for="(sd,idx) in jjhggsd">
				<image :src="'../../static/img/chekuang/'+sd.icon" class="kjhjbnhgse cf cz" mode="widthFix"></image>
				<text class="cz ml20">{{sd.name}}</text>
			</view>
		</view>
	</view>
</template>
<script>
	import tabqihuan from "./components/tabqihuan.vue"
	export default {
		data() {
			return {
				idsdf:1,
				ihbhbgsd:'',
				pkjkjjsd:[
					{
						id:0,
						images: 'car.png',
						xiaji:[
							{
								name: '大灯',
								zt:'关闭',
							},
							{
								name: '四闪',
								zt:'关闭'
							},
							{
								name: '小灯',
								zt:'关闭'
							},
							{
								name: '尾灯',
								zt:'关闭'
							}
						]
					},{
						id:1,
						images: 'car.png',
						xiaji:[
							{
								name: '左前门',
								zt:'关闭'
							},
							{
								name: '右前门',
								zt:'关闭'
							},
							{
								name: '左后门',
								zt:'关闭'
							},
							{
								name: '右后门',
								zt:'关闭'
							}
						]
					},{
						id:2,
						images: 'car.png',
						xiaji:[
							{
								name: '左前窗',
								zt:'关闭'
							},
							{
								name: '右前窗',
								zt:'关闭'
							},
							{
								name: '左后窗',
								zt:'关闭'
							},
							{
								name: '右后窗',
								zt:'关闭'
							}
						]
					},{
						id:3,
						images: 'chemenc.png'
					}
				],
				jjhggsd:[
					{
						name:'车灯',
						icon:'dsfdsa.png'
					},{
						name:'车门',
						icon:'dsfdsb.png'
					},{
						name:'车窗',
						icon:'dsfdsc.png'
					},{
						name:'胎压',
						icon:'dsfdsd.png'
					}
				],
				datas:{
					yq:false,
					carwei:false,
					chaungl1:false,
					chuangl2:false,
					chuangr1:false,
					chuangr2:false,
					doorl1:false,
					doorl2:false,
					doorr1:false,
					doorr2:false,
					car_HeadlightOn:false,
					car_fshan:false,
					car_weil:false,
				},
				interval:''
			}
		},
		components: {
			tabqihuan
		},
		onLoad() {
			
		},
		onShow() {
			let that = this
			//获取上一个页面实例
			let pages = getCurrentPages();
			let prevPage = pages[pages.length-2];
			that.datas.yq = prevPage.$vm.yq
			
			that.datas.carwei = prevPage.$vm.carwei
			
			that.datas.chaungl1 = prevPage.$vm.chaungl1
			that.datas.chuangl2 = prevPage.$vm.chuangl2
			that.datas.chuangr1 = prevPage.$vm.chuangr1
			that.datas.chuangr2 = prevPage.$vm.chuangr2
			that.interval = setInterval(function(){
				// console.log("++++++++++++++++++++++++++");
				that.datas.doorl1 = prevPage.$vm.doorl1
				if(that.datas.doorl1){
					that.pkjkjjsd[1].xiaji[0].zt = "开启"
				}else{
					that.pkjkjjsd[1].xiaji[0].zt = "关闭"
				}
				that.datas.doorl2 = prevPage.$vm.doorl2
				if(that.datas.doorl2){
					that.pkjkjjsd[1].xiaji[2].zt = "开启"
				}else{
					that.pkjkjjsd[1].xiaji[2].zt = "关闭"
				}
				that.datas.doorr1 = prevPage.$vm.doorr1
				if(that.datas.doorr1){
					that.pkjkjjsd[1].xiaji[1].zt = "开启"
				}else{
					that.pkjkjjsd[1].xiaji[1].zt = "关闭"
				}
				// that.datas.doorr2 = true
				that.datas.doorr2 = prevPage.$vm.doorr2
				if(that.datas.doorr2){
					that.pkjkjjsd[1].xiaji[3].zt = "开启"
				}else{
					that.pkjkjjsd[1].xiaji[3].zt = "关闭"
				}
				that.datas.car_HeadlightOn = prevPage.$vm.car_HeadlightOn
				// that.datas.car_HeadlightOn = true
				if(that.datas.car_HeadlightOn){
					that.pkjkjjsd[0].xiaji[0].zt = "开启"
				}else{
					that.pkjkjjsd[0].xiaji[0].zt = "关闭"
				}
				that.datas.car_fshan = prevPage.$vm.car_fshan
				if(that.datas.car_fshan){
					that.pkjkjjsd[0].xiaji[1].zt = "开启"
				}else{
					that.pkjkjjsd[0].xiaji[1].zt = "关闭"
				}
				that.datas.car_weil = prevPage.$vm.car_weil
				// that.datas.car_weil = true
				if(that.datas.car_weil){
					that.pkjkjjsd[0].xiaji[3].zt = "开启"
				}else{
					that.pkjkjjsd[0].xiaji[3].zt = "关闭"
				}
			// 更新数据
			//更新上一页面视图层数据
			},1000);
			
		},
		onUnload() {
			// console.log('--------------');
			clearInterval(this.interval);//停止
		},
		methods: {
			qoehuan(idx){
				if(idx == 3){
					uni.showToast({
						title:"即将上线",
						icon:"none"
					})
					return
				}
				this.idsdf = idx
				// console.log(this.idsdf);
				this.ihbhbgsd = this.pkjkjjsd[this.idsdf]
				// console.log('++++++++++++++++++++++=');
			}
		},
		mounted() {
			this.ihbhbgsd = this.pkjkjjsd[this.idsdf]
		}
	}
</script>
<style scoped>
	


	.parentssert {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		grid-template-rows: repeat(2, 1fr);
		grid-column-gap: 48upx;
		grid-row-gap: 48upx;
		margin-top: 140upx;
	}
	.jjhnmkhbnkdt{
		height:120upx;
		text-align: center;
		line-height: 120upx;
		background:rgba(53,60,81,1);
		box-shadow:0upx 6upx 12upx rgba(0,0,0,0.55);
		border-radius:12upx;
	}
	.jjhnmkhbnkdt.act{
		background:rgba(22,137,213,1);
	}
	.kjhjbnhgse{
		width: 60upx;
	}
</style>
